package com.topscore.uke.mvp.model;

import com.topscore.uke.entities.HotWordItem;
import com.topscore.uke.mvp.contractors.GetHotWordContractor;
import com.topscore.uke.network.BaseResponse;
import com.topscore.uke.network.retrofit.HandleErrorSubscriber;

import java.util.List;

import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by 71468 on 2018/3/20.
 */

public class GetHotWordModel implements GetHotWordContractor,GetHotWordContractor.Model {
    private CallBack mCallBack;

    public GetHotWordModel(CallBack callBack) {
        this.mCallBack = callBack;
    }

    @Override
    public void getHotWord() {
        mService.getHotWord()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .unsubscribeOn(Schedulers.io())
                .subscribe(new HandleErrorSubscriber<BaseResponse<List<HotWordItem>>>(mCallBack) {
                    @Override
                    public void onSuccess(BaseResponse<List<HotWordItem>> response) {
                        mCallBack.onGetHotWordSuccess(response);
                    }
                });
    }
}
